package com.yu.work.util;

import android.widget.Button;

import com.yu.work.R;

/**
 * 切换抽号开关的样式
 */
public class DrawNumberSwitchUtils {

    private static final String START = "开始抽号";
    private static final String STOP = "停止抽号";
    private static final int START_BG_RESOURCE = R.drawable.ripple_dark_bg_theme;
    private static final int STOP_BG_RESOURCE = R.drawable.ripple_dark_bg_warn;

    /**
     * 切换按钮样式并且返回一个boolean类型的值
     * 如果按钮切换为 stop 样式就返回true,否则返回false
     * @param btn
     * @return
     */
    public static boolean toggle(Button btn) {
        String text = btn.getText().toString();

        if (START.equals(text)) {
            btn.setText(STOP);
            btn.setBackgroundResource(STOP_BG_RESOURCE);
            return true;
        } else if (STOP.equals(text)) {
            btn.setText(START);
            btn.setBackgroundResource(START_BG_RESOURCE);
            return false;
        }

        return false;
    }
}
